<?php
	//1.链接数据库
	$conn=mysqli_connect('localhost','root','root','mydate');
	//设置链接过程中存取数据的编码
	mysqli_query($conn,"set charset 'utf8'");
	mysqli_query($conn,"set character set 'utf8'");
	
	//一：获取数据库数据
	//2.编写sql语句
	//查询数据
	$sql="select * from shop2";
		
	//3.执行sql语句,结果得到的是一个资源	
	$res=mysqli_query($conn,$sql);
	//获取
	$list = array();
	while($row=mysqli_fetch_assoc($res)){
		array_push($list,$row);
		
	}
	// 4.
	echo json_encode(array(
		"code" => 200,
		"body" => array(
			"list" => $list			
		)
	));
	
?>